﻿using MediatR;
using SystemWFH.API.Application.Command.ReviewCommand;
using SystemWFH.Infrstructer.Impl;
using SystemWFH.Infrstructer.Interface;

namespace SystemWFH.API.Application.CommandHandlers.ReviewCommandHandler
{
    public class ReviewDeletesCommandHandler : IRequestHandler<ReviewDeletesCommand, int>
    {
        private readonly IReviewRepository repository;
        public ReviewDeletesCommandHandler(IReviewRepository repository)
        {
            this.repository = repository;
        }
        public async Task<int> Handle(ReviewDeletesCommand request, CancellationToken cancellationToken)
        {
            var list = await repository.GetValue(request.reviewId);
            list.IsDelete = true;
            list.DelectTime = DateTime.Now.ToUniversalTime();
            list.DelectName = "李明";
            return await repository.UpdateAsync(list);
        }
    }
}
